package com.example.config;

import com.example.bean.Teacher;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;

@Configuration
public class BeanScopeConfig {

    @Bean
//    @Scope("singleton")
    public Teacher singletonTeacher(){
        return new Teacher(1, "t1");
    }

    @Bean
    @Scope("prototype")
    public Teacher prototypeTeacher(){
        System.out.println("BeanScopeConfig.prototypeTeacher");
        return new Teacher(2, "t2");
    }

    @Bean
    @Scope("singleton")
    public Teacher lazySingletonTeacher(){
        System.out.println("BeanScopeConfig.lazySingletonTeacher");
        return new Teacher(3, "lazyT3");
    }

    @Bean
    @Scope("singleton")
    @Lazy
    public Teacher lazySingleton(){
        System.out.println("BeanScopeConfig.lazySingleton");
        return new Teacher(3, "lazyT3");
    }
}
